package com.neusoft.a132wxyorderingdish.fragments;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.TextView;

import com.neusoft.a132wxyorderingdish.R;
import com.neusoft.a132wxyorderingdish.activity.AlterUserInfoActivity;
import com.neusoft.a132wxyorderingdish.beans.UserInfo;
import com.neusoft.a132wxyorderingdish.listener.RetrofitListener;
import com.neusoft.a132wxyorderingdish.model.ShopModel;


public class MyFragment extends BaseFragment implements RetrofitListener<UserInfo> {


    private TextView textView2,text3,user_money1,textView6,user_collect1,textView8,user_order1,textView10,textView11,user_name;
    private ImageButton user_setting,user_order,user_collect,user_money,profile_img;
    //private CircleImageView circleImageView;
    private UserInfo userInfo;


    @Override
    void initView() {
        textView2=view.findViewById(R.id.textView2);
        text3=view.findViewById(R.id.text3);
        user_money1=view.findViewById(R.id.user_money1);
        textView6=view.findViewById(R.id.textView6);
        user_collect1=view.findViewById(R.id.user_collect1);
        textView8=view.findViewById(R.id.textView8);
        user_order1=view.findViewById(R.id.user_order1);
        textView10=view.findViewById(R.id.textView10);
        textView11=view.findViewById(R.id.textView11);
        user_setting=view.findViewById(R.id.user_setting);
        user_order=view.findViewById(R.id.user_order);
        user_collect=view.findViewById(R.id.user_collect);
        user_money=view.findViewById(R.id.user_money);
        user_name=view.findViewById(R.id.user_name);
        //circleImageView=view.findViewById(R.id.profile_img);
        profile_img=view.findViewById(R.id.profile_img);

    }

    @Override
    void initEvent() {
        user_setting.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

            }
        });

        user_order.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

            }
        });

        user_collect.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //跳转到我的收藏

            }
        });

        user_money.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                initPopWindow(view);
            }
        });

        profile_img.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(context,AlterUserInfoActivity.class);
                intent.putExtra("username",userInfo.getUsername());
                intent.putExtra("address",userInfo.getAddress());
                intent.putExtra("phone",userInfo.getMobilenum());
                startActivity(intent);
            }
        });
    }

    @Override
    void initData() {
        ShopModel shopModel=new ShopModel();
        shopModel.getUserById(getUser_id(),this);

    }
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        setLayout_file(R.layout.fragment_my);
        // Inflate the layout for this fragment
        return super.onCreateView(inflater,container,savedInstanceState);

    }

    @Override
    public void onSuccess(UserInfo userInfo, int flag) {
        this.userInfo=userInfo;
        user_name.setText(userInfo.getUsername());
    }

    @Override
    public void onFail() {

    }

    private void initPopWindow(View v){

    }
}